<template>
	<view class="an-body an-user relative">
		
		<view class="an-top-bg" :class="company?'pb140r':'pb80r'" style="overflow: hidden;">
		<image src="../../static/img/logo_bg.png" :class="company? 'userbg':'userbg2'"></image>
			<!-- 用户信息 -->
			<view class="an-userInfo">
				<view class="an-user-image" style="box-shadow: 0 0 4px #5184ff;"><image mode="aspectFill" :src="userSrcnew | personimg" @error="imageError"></image></view>
				<view class="an-user-text">
					<view>
						<h3>{{ user_name }} 
							<span v-if='roleid==6' @tap="usercode('visitors')" class="mL5 usercode p2 f12 borderr8 pL5 pR5">访客二维码</span>
							<span v-else-if="roleid!=0" @tap="usercode('my')" class="mL5 usercode p2 f12 borderr8 pL5 pR5">二维码</span>
							<span class='f12 mL5' v-if="userinfo.role_name">{{userinfo.role_name}}</span>
						</h3>
						<view class="showcompany" v-if="userSrcnew&&!company">
							个人积分：{{member_frequency}} 
							<span class="mL5 borderb1" @click="gotomorey('u1')">积分记录</span>
							<span v-if="member_frequency==0" class="mL5 borderb1" @click="gotopup('1')">去充值</span>
							
						</view>
						<view class="showcompany" v-if="roleid">
							<p>{{ company }}</p>
							<p>
								<span v-if="roleid==2">
									<span v-if="companyinfodata.frequency==0&&companyinfodata.is_onepay==0" class=" borderb1 col_red" @click="gotopup2('2')" style="font-weight: bold;color:#e74a39;">升级正式版</span>
									<span v-if="companyinfodata.frequency!=0&&companyinfodata.is_onepay==0" class=" ">试用版</span>
									<span v-if="companyinfodata.is_onepay==1" class="col_ye "><image class='icopngimg' mode="aspectFill" src="../../static/img/icopng.png" @error="imageError"></image>正式版</span>
								</span>
								<span v-if="roleid!=2">
									<span v-if="companyinfodata.frequency!=0&&companyinfodata.is_onepay==0" class=" ">试用版</span>
									<span v-if="companyinfodata.is_onepay==1" class="col_ye "><image class='icopngimg'  mode="aspectFill" src="../../static/img/icopng.png" @error="imageError"></image>正式版</span>
								</span>
							</p>
							<p class="an-user-role"> <span class="col_red" v-if="userinfo.roleid==2&&company_status==0">（公司审核中）</span></p>
							<!-- <p v-if="!company_status">等待审核中...</p> -->
							<!-- :class="{'redRoom': Number(items.status) === 1, 'greenRoom1': Number(items.status) === 2, greenRoom2: Number(items.status) > 2}" -->
							<!-- <p v-if="memberchanger" class="an-user-memberstips">{{membertips}}</p> -->
						</view>
						<view class="showcompany" v-if="!roleid" >
							<view v-if="tipschanger">
							<text v-if="userinfo.is_completeperson!='1'">申请企业认证</text>
							<text class="borderb1" v-if="userinfo.is_completeperson=='1'" @click="gouseridcard()">实名认证</text>
							<br/>
							
							<!-- <text class="tips-text" >如果您是企业经营者请申请</text> -->
							<!-- <text class="tips-text" @tap="bindingcompany()">如果您是员工请<span>绑定公司</span>.</text> -->
							</view>
							
							<view v-if="!tipschanger">
							<br/>
							<text style="margin-top: -20upx;">企业信息审核中，请稍等...</text>
							<br/>
							<!-- <text class="tips-text" @tap="bindingcompany()">如果您是员工请<span>绑定公司</span>.</text> -->
							</view>
							
						</view>
					</view>
				</view>
				<!-- <view @click="goqrcode()" class="an-user-qrcode mT20 mL50"><icon class="iconfont  icon-erweima" size="32"/></view> -->
				
			</view>
			
			<view class="showfrequency" v-if="company">
				<view class="an-quick tCenter p10">
					<view class="list01 w50">
						<!-- <view></view> -->
						<div class="f12" style="font-size: 14px;">
							个人积分：{{member_frequency}}  <span v-if="member_frequency==0" class="mL5 borderb1" @click="gotopup('1')">去充值</span>
							<div class="col_ye" @click="gotomorey('u1')" style="border-bottom: 1px solid yellow;width:58px;text-align:center;margin:auto;line-height: 19px;">积分记录</div>
						</div>
					</view>
					<view class="list01 w50 ">
						<!-- <view class="">
						</view> -->
						<div class="f12 borderL1" style="font-size: 14px;">
							公司积分：{{member_cfrequency}} 
							<span v-if="roleid==2">							
								<span v-if="companyinfodata.frequency==0&&companyinfodata.is_onepay==1" class="mL5 borderb1" @click="gotopup('2')">去充值</span>
							</span>
							<div class="col_ye" @click="gotomorey('c1')" style="border-bottom: 1px solid yellow;width:58px;text-align:center;margin:auto;line-height: 19px;">积分记录</div>
						</div>
					</view>
					
					
				</view>
				
			</view>
		</view>
		
		<view class="an-body" :style="company?'top: 0upx;':'top: 0upx;'" style="margin-top: 20rpx;">
			<!-- <view class="w100 mauto uservipimg"  v-if="memberchanger" @tap="gomember()"> 
				<image an-radius-body src="../../static/img/uservip.jpg" mode="widthFix" class="w100"></image>
			</view> -->
			<view class="an-list">
				<view class="uni-list">
					<view class="uni-list-cell-divider newclassdivider" style="color: #898a89;">我是受访人</view>

					<view class="an-quick">										
						<view class="an-ico-item" @tap="clickBtn(11)">
							<view class="an-ico-img" :class="[expiredshow ||roleid==0 || roleid==6 || roleid==5?'an-ico-ban':'color1']"><span class="iconfontal">&#xe616;</span></view>
							<text class="an-ico-text">被约待审</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn(1)"  v-if="roleid!=5 && roleid!=6">
							<view class="an-ico-img" :class="[expiredshow ||roleid==0 ?'an-ico-ban':'color1']"><span class="iconfontal">&#xe688;</span></view>
							<text class="an-ico-text">我的邀请</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn(12)" v-if="roleid ==5 || roleid ==6">
							<view class="an-ico-img" :class="[expiredshow ||roleid==0?'an-ico-ban':'color1']"><span class="iconfontal">&#xe6ba;</span></view>
							<text class="an-ico-text">来访记录</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn(2)">
							<view class="an-ico-img" :class="[expiredshow ||roleid==0?'an-ico-ban':'color2']"><span class="iconfontal">&#xe64e;</span></view>
							<text class="an-ico-text">计划来访</text>
						</view>

						<view class="an-ico-item" @tap="clickBtn(3)">
							<view class="an-ico-img" :class="[expiredshow || roleid==0?'an-ico-ban':'color2']"><span class="iconfontal">&#xe60f;</span></view>
							<text class="an-ico-text">访客管理</text>
						</view>

						
					</view>
					<view class="an-quick" style="text-align: left;">
						<view class="an-ico-item" @tap="clickBtn(4)">
							<view class="an-ico-img" :class="[expiredshow || roleid==0?'an-ico-ban':'color3']"><span class="iconfontal">&#xe635;</span></view>
							<text class="an-ico-text">培训管理</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn(5)">
							<view class="an-ico-img" :class="[expiredshow || roleid==0?'an-ico-ban':'color3']"><span class="iconfontal">&#xe66f;</span></view>
							<text class="an-ico-text">部门管理</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn2(1)" v-if="roleid==0">
							<view class="an-ico-img" :class="[tipschanger?'color4':'color4']" ><span class="iconfontal">&#xe6a8;</span></view>
							<text class="an-ico-text">企业认证</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn2(2)" v-if="roleid==0">
							<view class="an-ico-img " :class="[tipschanger?'color4':'color4']" ><span class="iconfontal">&#xe679;</span></view>
							<text class="an-ico-text">加入公司</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn3(1)" v-if="roleid!=0">
							<view class="an-ico-img" :class="[roleid==0?'an-ico-ban':'color4']"><span class="iconfontal">&#xe679;</span></view>
							<text class="an-ico-text">企业信息</text>
						</view>
						
						<view class="an-ico-item" @tap="clickBtn2(3)" v-if="roleid!=0">
							<view class="an-ico-img " :class="[tipschanger?'an-ico-ban':'color4']"><span class="iconfontal">&#xe6cd;</span></view>
							<text class="an-ico-text">受访统计</text>
						</view>
					</view>
					<!-- <view style="width: 100%;height: 10px;background: #f7f7f7;" v-if="memberchangerpay" ></view>
					<view class="an-Member" v-if="memberchangerpay" @tap="gomember()">
						
						<text class="an-ico-text Member-h1">
							<span class="iconfont  icon-lv_zuanshi"></span>
							<span class="iconfont  icon-lv_zuanshi"></span>
							会员中心</text>
						
						<view style="text-align: right;">
							<text class="an-ico-text Member-h3"><span class="iconfont  icon-huiyuan"></span>开通使用权</text>
						</view>
					</view> -->
					
					<view style="width: 100%;height: 10px;background: #f7f7f7;"></view>
					<view class="uni-list-cell-divider newclassdivider" style="color: #898a89;">我是访客</view>

					<view class="an-quick" style="text-align: left;">
						<view class="an-ico-item" @tap="clickBtn4(8)">
							<view class="an-ico-img color5"><span class="iconfontal">&#xe65e;</span></view>
							<text class="an-ico-text">我要预约</text>
						</view>
						<view class="an-ico-item" @tap="clickBtn4(6)">
							<view class="an-ico-img color5"><span class="iconfontal">&#xe606;</span></view>
							<text class="an-ico-text">我的预约</text>
						</view>
						
						<view class="an-ico-item" @tap="clickBtn4(10)">
							<view class="an-ico-img color5"><span class="iconfontal">&#xe7b3;</span></view>
							<text class="an-ico-text">我被邀请</text>
						</view>
						
						<view class="an-ico-item" v-if="userinfo.is_completeperson=='1'" @click="gouseridcard()">
							<view class="an-ico-img color5"><span class="iconfont  icon-wode"></span></view>
							<text class="an-ico-text">实名认证</text>
						</view>
						
					</view>
					
					<!-- <view class="an-quick" style="text-align: left;">
						
					</view> -->

					<!-- <view style="width: 100%;height: 10px;background: #f7f7f7;"></view>

					<view class="uni-list-cell-divider">公共信息</view>

					<view class="an-quick" style="text-align: left;" >
						<view class="an-ico-item" @tap="clickBtn(7)">
							<view class="an-ico-img color4"><span class="iconfont  icon-wode"></span></view>
							<text class="an-ico-text">个人信息</text>
						</view>
					</view> -->
					<!-- <view class="an-quick" style="text-align: left;" v-if="company">
						<view class="an-ico-item" @tap="clickBtn(7)">
							<view class="an-ico-img color4"><span class="iconfont  icon-wode"></span></view>
							<text class="an-ico-text">账户管理</text>
						</view>
					</view> -->

					<!-- <view class="uni-list-cell" hover-class="uni-list-cell-hover" @tap="editPwd">
						<view class="uni-list-cell-navigate uni-navigate-right">
							<view class="an-ico color1"><span class="iconfont icon-xiugaimima"></span></view>
							<view>修改密码</view>
						</view>
					</view>
					<view class="uni-list-cell" hover-class="uni-list-cell-hover">
						<view class="an-none-arrow uni-list-cell-navigate uni-navigate-right">
							<view class="an-ico color2"><span class="iconfont icon-icon-test1"></span></view>
							<view>版本号</view>
							<view class="an-right">V1.0</view>
						</view>
					</view> -->
					<!-- <view class="uni-list-cell uni-list-cell-last" hover-class="uni-list-cell-hover" @tap="bindLogout">
						<view class="uni-list-cell-navigate uni-navigate-right">
							<view class="an-ico color3"><span class="iconfont icon-tuichu"></span></view>
							<view>退出登录</view>
						</view>
					</view> -->

					<view style="width: 100%;height: 50px;"></view>
				</view>
			</view>
		</view>
		 <loading v-if="!isloading()"></loading>
		<!-- 底部导航 -->
		<footerTips></footerTips>
		<footernav pagePath='user'></footernav>
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import { hostRoot, img } from '@/common/util.js';
import request from '../../common/vmeitime-http/requstx.js'; //引进requst方法
import {GetDateDiff} from '@/common/common.js'
import defaultImg from '@/static/img/userImg.jpg';
import {userinfo,codeadd_qrcode,codeget_qrcode} from '../../common/api/user.js'; //引进requst方法
const icoList = [
	{
		id: 1,
		ico: 'icon-icon-test7',
		text: '文章管理',
		color: 'color1'
	},
	{
		id: 2,
		ico: 'icon-icon-test3',
		text: '留言管理',
		color: 'color2'
	},
	{
		id: 3,
		ico: 'icon-icon-test6',
		text: '打卡管理',
		color: 'color3'
	},
	{
		id: 4,
		ico: 'icon-wode',
		text: '用户管理',
		color: 'color4'
	}
];
export default {
	
	computed: {
		...mapState(['hasLogin', 'forcedLogin', 'userInfo'])
	},
	data() {
		return {
			member_frequency:0,
			member_cfrequency:0,
			userSrc: '',
			userSrcnew:'',
			grids: [],
			user_name: '',
			company: '',
			companyid:"",
			userinfo:[],
			roleid:"",
			memberchanger:false,
			memberchangerpay:false,
			memberinfo:[],
			membertips:'',
			tipschanger:false,
			longtime:false,
			company_status:"",
			companyinfodata:'',
			expiredshow:false,
		};
	},
	onLoad() {
		uni.getStorage({
			key: 'headimgurl',
			success: res => {
				console.log(res.data);
				this.userSrc = res.data;
				console.log(this.userSrc);
			}
		});
		
		uni.getStorage({
			key: 'userinfo',
			success: res => {
				console.log(res);

			}
		});

	},
	onShow() {
		
		this.loadingonshow();
		//监听页面显示。页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面
		this.grids = [];
		if (!this.hasLogin) {
			this.bindLogin();
		} else if (this.userInfo.grade == 2 || this.userInfo.grade == 3) {
			this.grids = icoList;
		} else {
			this.grids.push(icoList[0]);
			this.grids.push(icoList[1]);
		}
	},
	methods: {
		gouseridcard(){
			uni.navigateTo({
			    url: '../shouquan/shengfen',
			});
		},
		gotopup2(type){//去充值
		if(this.roleid==2){
			var msg="积分使用完毕，如需继续使用\r\n请支付系统费用"
		}else{
			var msg="积分使用完毕，如需继续使用\r\n请联系企业管理员"
		}
		uni.showModal({
		    title: '',
		    content: msg,
		    success: function (res) {
		        if (res.confirm) {
		            console.log('用户点击确定');
					uni.navigateTo({
						url: '/pages/member/umemeber2?type='+type
					});
		        } else if (res.cancel) {
		            console.log('用户点击取消');
		        }
		    }
		});
			
		},
		
		gotomorey(type){//去充值
			uni.navigateTo({
				url: '/pages/user/pointsrecord?type='+type
			});
		},
		gotopup(type){//去充值
			uni.navigateTo({
				url: '/pages/member/umemeber?type='+type
			});
		},
		backRefresh(type){ //返回刷新带参数
			// window.location.reload()
			// this.onShow()
			this.loadingonshow();
			 this.$forceUpdate()
		},
		loadingonshow(){
			userinfo({}).then(res=>{//获取用户信息
				console.log(res)
				/* 400 */
				if(res.data.code==400){
					uni.showModal({
    					title: '提示',
						showCancel:false,
    					content: res.data.message,
    					success: function (clickres) {
    					    if (clickres.confirm) {
								uni.reLaunch({
								    url: '/pages/shouquan/shouji'
								});
    					    }
    					}
					});
				}

				this.user_name = res.data.data.name;
				if(res.data.data&&res.data.data.companyid){
					this.company= res.data.data.company_name;
					this.companyid = res.data.data.companyid;	
				}
				
				
				this.userSrcnew = res.data.data.personimg;
				this.userinfo = res.data.data;
				this.memberinfo = res.data.member;
				if(res.data.data&&res.data.data.roleid){
					this.roleid=res.data.data.roleid	
				}
				if(res.data&&res.data.companyinfo){
					this.companyinfodata= res.data.companyinfo;
					if(this.companyinfodata.frequency==0&&this.companyinfodata.is_onepay==0){
						this.expiredshow=true;
					}else if(this.userinfo.is_completeperson!='2' && res.data.companyinfo){
						this.expiredshow=true;
					}else{
						this.expiredshow=false;
					}
				}
				this.member_frequency=res.data.member.member_frequency;
				this.member_cfrequency=res.data.member.member_cfrequency;				
				if(this.roleid == 0 || this.roleid == 1 || this.roleid == 2){
					this.memberchanger = true
				}
				if(typeof(res.data.company_status)=="undefined"){
					this.tipschanger = true
				}
				if(res.data.company_status){
					this.company_status=res.data.company_status
				}
				if(this.roleid == 0){
					this.longtime=true;
				}	
				if(this.roleid==2){			
					if(res.data.member&& !res.data.member.member_expritime){
						this.memberchangerpay = true
					}else if(res.data.member&& res.data.member.member_expritime){
						let stopTime = new Date(res.data.member.member_expritime.replace(/-/g, '/')).getTime();
						let thistime = new Date().getTime();
						let newstoptimes=stopTime-24*60*60*1000;// 提前一天做提示
						if(thistime>newstoptimes){//判断是不是过期了
							this.memberchangerpay = true;
						}
					}
				}
				
				// if(this.roleid == 1 || this.roleid == 2){
				// 	 this.memberchangerpay = true
				// }
				this.membercheck()
				
				// codeadd_qrcode({type:"1",companyid:this.companyid}).then(rescode=>{
				// 	console.log(rescode)
				// 	codeget_qrcode({companyid:this.companyid,id:this.companyid}).then(rescodeget=>{
				// 		console.log(rescodeget)
				// 	})
					
				// })
				uni.setStorage({
				    key: 'userinfo',
				    data: res.data.data,
				    success: function () {
				        console.log('success');
				    },
					fail:function(){
						console.log('faild')
					}
				});
			})
		},
		goqrcode(){
			uni.navigateTo({
				url: '/pages/qrcode/usercode'
			});
		},
		/*expritime check member*/
		membercheck(){
			console.log(this.memberinfo)
			if(this.memberinfo.member_expritime!=null){
				var date = new Date(this.memberinfo.member_expritime);
				var time1 = date.getTime();
				// console.log(time1)
				var nowday = Date.parse(new Date())
				// console.log(nowday)
				// console.log(nowday>time1)
				if(nowday>time1){
					this.membertips=  '套餐已逾期'+GetDateDiff(time1,nowday)+'天';
				}else{
					this.membertips = '会员续费日期:'+this.memberinfo.member_expritime;
				}
			}			
		},
		gomember(){
			uni.navigateTo({
				url:'../member/umemeber'
			})
		},
		onReachBottom() {
			console.log('2')
		},
		...mapMutations(['logout']),
		bindingcompany(){
			uni.navigateTo({
				url: '/pages/shouquan/conpany'
				// url: '/pages/subject/problem'
			});
		},
		addcompany(){	
			// '/pages/user/certificationtype'
			uni.navigateTo({
				url: '../shouquan/yingye'
			});
		},
		clickBtn3(id){
			//0-未审核,1-未通过,2-已通过,3-禁用)
			if(this.company_status==0){
				uni.showModal({
				    title: '营业执照审核',
				    content: '您已提交营业执照审核申请,我们将在1-3个工作日内审核。审核通过后您可直接登录系统,如审核不通过,请修改信息后提交',
					showCancel:false,
				    success: function (res) {
				        if (res.confirm) {
				            console.log('用户点击确定');
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}else if(this.company_status==1){
				uni.showModal({
				    title: '营业执照审核',
				    content: '您已提交营业执照未通过',
					showCancel:false,
				    success: function (res) {
				        if (res.confirm) {
				            var url = '../user/enterprise_i';
				            uni.navigateTo({
				            	url: url
				            });	
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}else if(this.company_status==4){
				uni.showModal({
				    title: '营业执照审核',
				    content: '您提交的营业执照正在注册审核中',
					showCancel:false,
				    success: function (res) {
				        if (res.confirm) {
				            var url = '../user/enterprise_i';
				            uni.navigateTo({
				            	url: url
				            });	
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
			else if(this.company_status==5){
				uni.showModal({
				    title: '企业注销审核',
				    content: '您提交的企业注销正在注册审核中',
					showCancel:false,
				    success: function (res) {
				        if (res.confirm) {
				            var url = '../user/enterprise_i';
				            uni.navigateTo({
				            	url: url
				            });	
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
			/*可删除 Lastime:2021年4月22日14:58:42*/
			else if(this.userinfo.is_completeperson!='2'){
				uni.showModal({
					// title: '',
					content: '您准备成为企业管理员,请完成实名认证.',
					buttonText: '去认证',
					confirmText: "去认证",
					success: function (res) {
						if (res.confirm) {
						uni.navigateTo({
						    url: '../shouquan/shengfen',
						});
						} else if (res.cancel) {
							console.log('用户点击取消实名认证(后台已添加企业)');
						}
					}
				});
				return;
			}
			//end
			else{
				var url = '../user/enterprise_i';
				uni.navigateTo({
					url: url
				});	
			}
			
		},
		clickBtn2(id){
			if(this.userinfo.is_completeperson=='1'){
				// uni.showModal({
				//     title: '提示',
				//     content: '请完成实名认证后，再操作。',						
				// 	showCancel:false,
				// 	buttonText: '确定',
				// 	confirmText: "确定",
				//     success: function (res) {
				//         if (res.confirm) {
				//             console.log('用户点击确定');
				// 			// that.addcompany();//去认证公司
				//         } else if (res.cancel) {
				//             console.log('用户点击取消');
				//         }
				//     }
				// });
				uni.showModal({
					title: '',
					content: '您还没实名认证\r\n请实名认证后再操作',						
					
					buttonText: '去认证',
					confirmText: "去认证",
					success: function (res) {
						if (res.confirm) {
							uni.navigateTo({
							    url: '../shouquan/shengfen',
							});
							
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
				
				return;
			}
			
			try{				
				
				if(!this.tipschanger && this.company_status!=2){
					uni.showModal({
					    title: '提示',
					    content: '您已经提交了资料,\r\n请等待审核',						
						showCancel:false,
						buttonText: '确定',
						confirmText: "确定",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								// that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}
			}catch(e){
				//TODO handle the exception
					uni.showModal({
					    title: '提示',
					    content: '您已经提交了资料,\r\n请等待审核',						
						showCancel:false,
						buttonText: '确定',
						confirmText: "确定",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								// that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
	
			}
			// if(!this.tipschanger){
			// 	uni.showModal({
			// 	    title: '提示',
			// 	    content: '企业认证审核中,请等待',						
			// 		showCancel:false,
			// 		buttonText: '确定',
			// 		confirmText: "确定",
			// 	    success: function (res) {
			// 	        if (res.confirm) {
			// 	            console.log('用户点击确定');
			// 				// that.addcompany();//去认证公司
			// 	        } else if (res.cancel) {
			// 	            console.log('用户点击取消');
			// 	        }
			// 	    }
			// 	});
			// 	return
			// }
			let url = '';
			switch (id) {
				case 1:
					url = '../shouquan/yingye';
					break;
				case 2:
					url = '../shouquan/conpany';
					break;
				case 2:
					url = '../main/main';
					break;
				default:
					url = '../main/main';
			}
			if(this.expiredshow){
				this.expired();
				return;
			}
			uni.navigateTo({
				url: url
			});	
		},
		expired(){
			let that=this;
			if(this.roleid==2){
				var msg="积分使用完毕，如需继续使用\r\n请支付系统费用"
			}else{
				var msg="积分使用完毕，如需继续使用\r\n请联系企业管理员"
			}
			uni.showModal({
				title: '',
				content: msg,	
				buttonText: '确定',
				confirmText: "确定",
				success: function (res) {
					if (res.confirm) {
						console.log('用户点击确定');
						if(that.roleid==2){
							uni.navigateTo({
								url: '/pages/member/umemeber2'
							});
						}
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		clickBtn4(id) {
			var that=this;
			// console.log(id != 6 || id !=7)


			if(this.roleid ==0){
				if(id != 10 && id != 6 && id !=7 && id!=8){					
					uni.showModal({
					    title: '提示',
					    content: '企业负责人请选择“企业认证”\r\n企业受访人请选择“加入公司”',						
						showCancel:false,
						buttonText: '确定',
						confirmText: "确定",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								// that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}	 
			}
			if(id ==1 || id == 11){
				if(this.roleid == 5 || this.roleid == 6){
					uni.showModal({
					    title: '提示',
					    content: '抱歉,您还没认证管理员，去认证。',						
						showCancel:false,
						buttonText: '去认证',
						confirmText: "去认证",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								//that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}
				// if(this.userinfo&&this.userinfo.Interviewees==0){
				// 	uni.showModal({
				// 		title: '提示',
				// 		content: '抱歉,您还没认证管理员，去认证。',
				// 		showCancel:false,
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('用户点击确定');
				// 				//that.addcompany();//去认证公司
				// 			} else if (res.cancel) {
				// 				console.log('用户点击取消');
				// 			}
				// 		}
				// 	});
				// 	return
				// }
				
			}
			if(id==1||id==2||id==3||id==4||id==5||id==11){
				if(this.expiredshow){
					this.expired();
					return;
				}
				if(this.company_status!=2){ //营业执照审核
					uni.showModal({
						title: '提示',
						content: '抱歉,营业执照未审核或审核不通过，暂时不能操作其它功能',
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
								//that.addcompany();//去认证公司
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return 
				}
				if(!this.userinfo.deptid&&this.roleid!=2){
					uni.showModal({
						title: '提示',
						content: '抱歉,操作状态暂未恢复，请联系部门经理',
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
								//that.addcompany();//去认证公司
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return 
				}
				
				
			}
			 
			if(this.roleid == 4 || this.roleid == 5 || this.roleid == 6){
				if(id ==4){
					uni.showModal({
					    title: '提示',
					    content: '抱歉,您还没认证管理员，去认证。',
						showCancel:false,
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								//that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}	
			}
			let url = '';
			switch (id) {
				case 11:
					url = '../comster/comster_adu';
					break;
				case 12:
					url = '../yaoqing/laifangjilu';
					break;	
				case 1:
					url = '../yaoqing/yaoqinglist';
					break;
				case 2:
					url = '../yuyuejilu/yuyuejilu';
					break;
				case 3:
					url = '../comster/comster';
					break;
				case 4:
					url = '../Trainingtopics/trainingTopicslist';
					break;
				case 5:
					url = '../Departmentmanagement/departmentManagement';
					break;
				case 6:
					url = '../myyuyue/myyuyue?type=1';
					uni.reLaunch({
						url:url
					})
					break;
				case 7:
					url = '../user/userMessage';
					break;
				case 8:
					url = '../yaoqing/useraddvisitors';
					break;
				case 9:
					url = '../user/enterprise_i';
					break;
				case 10:
					url = '../myyuyue/myyuyue?type=2';
					uni.reLaunch({
						url:url
					})
					break;
				default:
					url = '../main/main';
			}
			if(id==8){
				if(this.userinfo.is_completeperson=='1'){					
					uni.showModal({
						title: '',
						content: '您还没实名认证\r\n请实名认证后再操作',						
						
						buttonText: '去认证',
						confirmText: "去认证",
						success: function (res) {
							if (res.confirm) {
								uni.navigateTo({
								    url: '../shouquan/shengfen',
								});
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					
					return;
				}
				
			}
			if(id==5){
				if(this.roleid&&this.roleid==1||this.roleid&&this.roleid==2){
					// uni.navigateTo({
					// 	url: '../Departmentmanagement/departmentManagement'
					// });
					uni.navigateTo({
						url: url
					});
					
				}else{
					let detail = {
						id: this.userinfo.deptid,
						companyid: this.userinfo.companyid,
						departname: this.userinfo.dept_name,
						employees: 'YES',
					};
					uni.navigateTo({
						url: '../Departmentmanagement/departmentPersonnel?detaildata=' + encodeURIComponent(JSON.stringify(detail))
					});
				}	
			}else{
				uni.navigateTo({
					url: url
				});	
			}
			
		},
		clickBtn(id) {
			var that=this;
			console.log("走了这里")
			// console.log(id != 6 || id !=7)
			try{
				if(!this.tipschanger && this.company_status!=2){
					uni.showModal({
					    title: '提示',
					    content: '您已经提交了资料,\r\n请等待审核',						
						showCancel:false,
						buttonText: '确定',
						confirmText: "确定",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								// that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}
			}catch(e){
				//TODO handle the exception
					uni.showModal({
					    title: '提示',
					    content: '您已经提交了资料,\r\n请等待审核',						
						showCancel:false,
						buttonText: '确定',
						confirmText: "确定",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								// that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
		
			}

			if(this.roleid ==0){
				if(id != 10 && id != 6 && id !=7 && id!=8){					
					uni.showModal({
					    title: '提示',
					    content: '企业负责人请选择“企业认证”\r\n企业受访人请选择“加入公司”',						
						showCancel:false,
						buttonText: '确定',
						confirmText: "确定",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								// that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}	 
			}
			if(id ==1 || id == 11){
				if(this.roleid == 5 || this.roleid == 6){
					uni.showModal({
					    title: '提示',
					    content: '抱歉,您还没认证管理员，去认证。',						
						showCancel:false,
						buttonText: '去认证',
						confirmText: "去认证",
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								//that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}
				// if(this.userinfo&&this.userinfo.Interviewees==0){
				// 	uni.showModal({
				// 		title: '提示',
				// 		content: '抱歉,您还没认证管理员，去认证。',
				// 		showCancel:false,
				// 		success: function (res) {
				// 			if (res.confirm) {
				// 				console.log('用户点击确定');
				// 				//that.addcompany();//去认证公司
				// 			} else if (res.cancel) {
				// 				console.log('用户点击取消');
				// 			}
				// 		}
				// 	});
				// 	return
				// }
				
			}
			if(id==1||id==2||id==3||id==4||id==5||id==11 ||id==12){
				if(this.expiredshow && 
				   this.userinfo.is_completeperson!='2' && 
				   this.userinfo.roleid=='2' &&
				   this.companyinfodata
				   ){
					   uni.showModal({
					   	// title: '',
					   	content: '您准备成为企业管理员,请完成实名认证.',
						buttonText: '去认证',
						confirmText: "去认证",
					   	success: function (res) {
					   		if (res.confirm) {
								uni.navigateTo({
								    url: '../shouquan/shengfen',
								});
					   		} else if (res.cancel) {
					   			console.log('用户点击取消实名认证(后台已添加企业)');
					   		}
					   	}
					   });
					   return;
					   
				   }else if(this.expiredshow){
					   this.expired();
					   return;
				   }
				if(this.company_status!=2){ //营业执照审核
					uni.showModal({
						title: '提示',
						content: '抱歉,营业执照未审核或审核不通过，暂时不能操作其它功能',
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
								//that.addcompany();//去认证公司
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return 
				}
				if(!this.userinfo.deptid&&this.roleid!=2){
					uni.showModal({
						title: '提示',
						content: '抱歉,操作状态暂未恢复，请联系部门经理',
						showCancel:false,
						success: function (res) {
							if (res.confirm) {
								console.log('用户点击确定');
								//that.addcompany();//去认证公司
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return 
				}
				
				
			}
			 
			if(this.roleid == 4 || this.roleid == 5 || this.roleid == 6){
				if(id ==4){
					uni.showModal({
					    title: '提示',
					    content: '抱歉,您还没认证管理员，去认证。',
						showCancel:false,
					    success: function (res) {
					        if (res.confirm) {
					            console.log('用户点击确定');
								//that.addcompany();//去认证公司
					        } else if (res.cancel) {
					            console.log('用户点击取消');
					        }
					    }
					});
					return
				}	
			}
			let url = '';
			switch (id) {
				case 11:
					url = '../comster/comster_adu';
					break;
				case 12:
					url = '../yaoqing/laifangjilu';
					break;	
				case 1:
					url = '../yaoqing/yaoqinglist';
					break;
				case 2:
					url = '../yuyuejilu/yuyuejilu';
					break;
				case 3:
					url = '../comster/comster';
					break;
				case 4:
					url = '../Trainingtopics/trainingTopicslist';
					break;
				case 5:
					url = '../Departmentmanagement/departmentManagement';
					break;
				case 6:
					url = '../myyuyue/myyuyue?type=1';
					uni.reLaunch({
						url:url
					})
					break;
				case 7:
					url = '../user/userMessage';
					break;
				case 8:
					url = '../yaoqing/useraddvisitors';
					break;
				case 9:
					url = '../user/enterprise_i';
					break;
				case 10:
					url = '../myyuyue/myyuyue?type=2';
					uni.reLaunch({
						url:url
					})
					break;
				default:
					url = '../main/main';
			}
			if(id==5){
				if(this.roleid&&this.roleid==1||this.roleid&&this.roleid==2){
					// uni.navigateTo({
					// 	url: '../Departmentmanagement/departmentManagement'
					// });
					uni.navigateTo({
						url: url
					});
					
				}else{
					let detail = {
						id: this.userinfo.deptid,
						companyid: this.userinfo.companyid,
						departname: this.userinfo.dept_name,
						employees: 'YES',
					};
					uni.navigateTo({
						url: '../Departmentmanagement/departmentPersonnel?detaildata=' + encodeURIComponent(JSON.stringify(detail))
					});
				}	
			}else{
				uni.navigateTo({
					url: url
				});	
			}
			
		},
		usercode(type){
			// 用户二维码
			uni.navigateTo({
				url: '../qrcode/usercode?usertype='+type
			});
		},
		editPwd() {
			// 修改密码
			uni.navigateTo({
				url: '../pwd/pwd'
			});
		},
		bindLogin() {
			uni.navigateTo({
				url: '../login/login'
			});
		},
		bindLogout() {
			this.logout();
			uni.reLaunch({
				url: '../login/login'
			});
		},
		imageError(e) {
			this.userSrc = defaultImg;
		}
	}
};
</script>

<style lang="scss">
	
	page:before {
		width: 100%;
	   height: 100%;
	   content: ' ';
	   position: fixed;
	   z-index: -1;
	   top: 0;
	   left: 0;
	   background: #f5f7f6;
	}

	.userbg{
		width:100%;
		height: 100px;
		left:0;
		margin-top: 10.5%;
		position:absolute;
		z-index: -1;
		opacity: 0.8;
	}
	
	.userbg2{
		width:100%;
		height: 100px;
		left:0;
		margin-top: 7.5%;
		position:absolute;
		z-index: -1;
		opacity: 0.8;
	}
@font-face {
  font-family: 'iconfont';  /* project id 1807044 */
  src: url('//at.alicdn.com/t/font_1807044_z86q330c55.eot');
  src: url('//at.alicdn.com/t/font_1807044_z86q330c55.eot?#iefix') format('embedded-opentype'),
  url('//at.alicdn.com/t/font_1807044_z86q330c55.woff2') format('woff2'),
  url('//at.alicdn.com/t/font_1807044_z86q330c55.woff') format('woff'),
  url('//at.alicdn.com/t/font_1807044_z86q330c55.ttf') format('truetype'),
  url('//at.alicdn.com/t/font_1807044_z86q330c55.svg#iconfont') format('svg');
}
	.iconfontal{
	    font-family:"iconfont" !important;
	    font-size:18px;font-style:normal;
	    -webkit-font-smoothing: antialiased;
	    -webkit-text-stroke-width: 0.2px;
	    -moz-osx-font-smoothing: grayscale;
	}
	.usercode{vertical-align: middle;    background: -webkit-linear-gradient(#78f5b1, #34ce78);
    background: linear-gradient(#78f5b1, #34ce78);}
	.uservipimg{border-radius: 8px;overflow:hidden;margin:0 auto;}
	.uservipimg uni-image{height: 4.2rem;}
	.newclassdivider{padding: 6px 19px;}
.an-user {
	.an-radius-body{position: inherit;    margin-top: -40rpx;}
	.pb140r{padding-bottom: 80rpx;}
	.pb80r{padding-bottom: 10rpx;}
	.an-top-bg{
		position: inherit;
		border-bottom-left-radius: 30px;
		border-bottom-right-radius: 30px;
		    padding-top: 30px;
		background: linear-gradient(to bottom right, rgba(0, 122, 255, 0.49), rgba(0, 122, 255, 0.5215686274509804));
		.an-user-image{
			image{
				width: 60px; 
				height: 60px; 
				background-color: #eeeeee;
			}
		}
		.an-userInfo view{
			line-height: 1.5;
		}

		.an-user-memberstips{
			font-size: 10px;
			
		}
		.tips-text{
			
			width: 100%;
			display: block;
			font-size: 12px;
			height: 16px;
			margin-top: -2px;
			// line-height: ;
			span{
				font-size: 14px;
				font-weight: bold;
				// color: #FF3333;
			}
		}
	}
	.an-quick {
		display: flex;
		flex-direction: row;

		padding: 15px 15px;
		.an-ico-item {
			width: 25%;
			text-align: center;
			.an-ico-ban{
				background: #cfcfcf;
			}
			.an-ico-img {
				box-shadow: 0 0 3px #C0C0C0;
				text-align: center;
				width: 40px;
				height: 40px;
				line-height: 40px;
				margin: 0 auto;
				border-radius: 50%;
				color: #ffffff;
				.iconfont {
					font-size: 21px;
				}
				&.color1 {
					//background-color: #e9f4fd;
					background: linear-gradient(#bb51fb, #883ffe);
				}
				&.color2 {
					background: linear-gradient(#f9ac8e, #ec5e5c);
				}
				&.color3 {
					background: linear-gradient(#78f5b1, #34ce78);
				}
				&.color4 {
					background: linear-gradient(#88f4e7, #4ed8cb); 
				}
				&.color5 {
					background: linear-gradient(#68aefb, #007aff); 
				}
			}
		}
	}
	.an-list {
		.an-ico {
			margin-right: 10px;
			.iconfont {
				font-size: 21px;
				
			}
			&.color1 {
				color: #ec5e5c;
			}
			&.color2 {
				color: #883ffe;
			}
			&.color3 {
				color: #34ce78;
			}
			&.color4 {
				color: #007aff;
			}
		}
	}
	.an-user-role{
		font-size: 18upx;
		color: #f2f2f2;
		icon{
			margin-right: 2px;
		}
	}
}
.uni-list-cell-divider {
	background-color: white;
}
.an-Member{
	background: linear-gradient(to right, #ffdb9d, #ffcc76, #f1bc65);
	.Member-h1{
		letter-spacing:4px;
		color: #cc8f1a;
		font-size: 20px;
		font-weight: bold;
		position: relative;
		top: 10px;
		left: -10px;
		}
	.Member-h2{
		opacity: 0.8;
		position: relative;
		top: 30px;
		left: -6%;
		margin: 10px;
		padding: 2px;
		background:#cc8f1a;
		color: #FFFFFF;
		border-radius: 10px;
		
	}
	.Member-h3{
		letter-spacing: 1rpx;
		font-size: 16px;
		color: #ffffff;
		border-radius: 10px 0 0 10px;
		position: relative;
		text-align: right;
		background: #e3a049;
		padding: 6px;
		top: -20px;
		
	}
	.icon-huiyuan{
		border-radius: 50%;
		background:#F2F2F2;
		color: #fbec21;
		// font-size: 20px;
	}
	
	.icon-lv_zuanshi{
		filter: #333;
		color: #3a384d;
		font-size: 20px;
		&:first-child{
			position: relative;
			left: 22px;
			font-size: 22px;
			color: #e07708;
			opacity: 0.3;
		}
	}
}
.col_ye{color: #fbec21;  vertical-align: sub;}
</style>
<style scoped>
	.an-user .an-top-bg .an-user-image uni-image{width: 60px;height: 60px;}
	.an-top-bg .an-userInfo .an-user-image{width: 60px;height: 60px;}
	.showfrequency .list01 {font-size: 12px;}
	.showfrequency .list01 uni-view{line-height: 30upx; font-size: 14px;}
	.icopngimg{    width: 1.2rem;
    height: 1.2rem;
	padding-right: 5px;
    vertical-align: inherit;}
</style>
